<template>
  <card title="合同信息" :showDivider="showDivider">
    <a-alert>
      <template #icon> <icon-exclamation-circle /> </template>上传格式：支持jpg、jpeg、png、doc、docx、pdf格式
    </a-alert>
    <div class="contContainer">
      <!-- 上传组件 -->
      <upload-attach class="upload-attach" v-model="form.contractList[0].contractFileId" @change="onUploadSuccess" />
    </div>
  </card>
</template>
<script setup>
  import { inject } from 'vue'
  import { getContractNo } from '@/api/order/czsOrder.js'
  const form = inject('form')

  // 上传完成
  const onUploadSuccess = (_, fileItem) => {
    const contract = form.value.contractList[0]
    // 更新合同文件名
    contract.contractName = fileItem.name

    // 如果没有合同编号，成合并编号
    if (!contract.contractNo) {
      getContractNo({ type: contract.contractType }).then((res) => {
        contract.contractNo = res.result
      })
    }
  }
</script>
<style lang="less" scoped>
  .contContainer {
    margin-top: 10px;
    .upload-attach {
      max-width: 460px;
    }
  }
</style>
